from django.contrib import admin
from aio.models import Player, Draw

class PlayersInline(admin.TabularInline):
    model = Player
    
class DrawAdmin(admin.ModelAdmin):
    
    fields = ('subject','body','language')

    list_display = ('creation_date', 'subject', 'language')
    list_filter = ('language',)
    
    inlines = [PlayersInline,]

    
    def change_view(self, *args, **kwargs):
        self.fields = ('subject','body',)
        return super(DrawAdmin, self).change_view(*args, **kwargs)

class PlayerAdmin(admin.ModelAdmin):
    
    fields = ('name','friend','email','pwd',
              'wish','dont_wish','got')

    list_display = ('name', 'email', 'draw',)
    search_fields = ['name','email']
    
    
    
admin.site.register(Player, PlayerAdmin)
admin.site.register(Draw, DrawAdmin)
